/**
 * 删除上传的图片
 */
function deleteCover(value) {
    $("#" + value).remove();
}

/**
 * 会员
 */

define([
    'jquery',
    'baseUtils',
    'base',
    'msgTool',
    'css!global/plugins/wangEditor/wangEditor.min.css',
    'plugins/wangEditor/wangEditor.min',
    'css!global/plugins/fileInput/fileinput.min.css',
    'plugins/fileInput/fileinput.min',
    'plugins/bootstrap-table/bootstrap-table',
    "plugins/bootstrap-dialog/bootstrap-dialog",
    "css!global/plugins/bootstrap-dialog/bootstrap-dialog.css",
    'iCheck',
    'css!global/plugins/iCheck/icheck.min.css'
], function ($, baseUtils, base, msgTool, _, E, _, _, _, BootstrapDialog,iCheck) {
    //默认加载基础库
    base();
    //执行
    return {
   	 info: function () {    
   		 
   		$("input[name='sex']").iCheck({
			checkboxClass: 'icheckbox_square-green',
			radioClass: 'iradio_square-green',
			increaseArea: '10%' // optional
		});

         /**
          * 提交食药从业人员申请
          */

         $("#submitTechnician").on('click', function () {
        	 var reg_phone = /^((1[3,5,8][0-9])|(14[5,7])|(17[0,6,7,8]))\d{8}$/;//验证手机号
 			 var reg_IDcard = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/; //验证身份证号
        	 var name = $("#name").val();
       	     var nation=$("#nation").val();
       	     var householdAddress=$("#householdAddress").val();
          	 var cardNumber= $("#cardNumber").val();
          	 var phone= $("#phone").val();
           if(name==''){
          	$("#name-error").html("(姓名不能为空)");
          	return false;
           }else{
            $("#name-error").html("");  
           }
           if(nation==''){
       	   $("#nation-error").html("(民族不能为空)");
       	   return false;
           }else{
           $("#nation-error").html("");  
           }
           if(householdAddress==''){
            $("#householdAddress-error").html("(户籍地址不能为空)");
            return false;
           }else{
        	$("#householdAddress-error").html("");   
           }
           if(cardNumber==''){
          	 $("#cardNumber-error").html("(证件号码不能为空)"); 
          	return false;
           }else{
        	   if(cardType==1){
              		if (!reg_IDcard.test(cardNumber)){
                   		  $("#cardNumber-error").html("请输入正确的证件号码");
          					return false;
          				}else{
          				  $("#cardNumber-error").html("");	
          				}	
              	}else{
              		 $("#cardNumber-error").html("");	
              	}        
           }
           if(phone==''){
          	 $("#phone-error").html("(手机号不能为空)");
          	return false;
           }else{
        	   if (!reg_phone.test(phone)){
            		  $("#phone-error").html("(请输入正确的手机号码)");
   					return false;
   				}else{
   				  $("#phone-error").html("");	
   				}
           }
           $("#saveApplyTechnicianForm").submit();
          });
         
         $("#cancelTechnician").on('click', function () {
         	var applyId=$("#applyId").val();
         	var changeId=$("#changeId").val();
         	if(changeId==undefined){
         		window.location.href="/fooddrugApply/technicianList?applyId="+applyId;
         	}
         	if(applyId==undefined){
         		window.location.href="/fooddrugChange/technicianList?changeId="+changeId;
         	}
         });
         
 
         
     },

    	 /**
         * 列表
         */
        list: function () {

            var myTable = $('#technicianList');
            var tableRefresh = function () {
                myTable.bootstrapTable('refresh', {url: 'member/api.json'})
            };

            //table当前行的响应事件
            window.operateEvents = {
                'click .update': function (e, value, row) {
                    winModal("编辑", row);
                },
                'click .status': function (e, value, row) {
                    $.baseUtils.oneStatus({
                        row: row,
                        tableName: myTable,
                        nameText: '姓名',
                        nameValue: row.name,
                        url: '/user/project/status/action'
                    });
                },
                'click .delete': function (e, value, row) {
                    $.baseUtils.oneDelete({
                        row: row,
                        tableName: myTable,
                        nameText: '姓名',
                        nameValue: row.name,
                        url: '/fooddrug/deleteEmployee/action'
                    });
                }
            };

            //table表格
            myTable.bootstrapTable({
                url: 'member/api.json', // 接口 URL 地址
                cache: false, // 不缓存
                striped: true, // 隔行加亮
                pagination: true, // 开启分页功能
                sidePagination: 'server',//服务端分页
                sortOrder: 'desc', // 设置排序为反序 desc
                fixedColumns: true,//自动修复
                queryParams: queryParams,//搜索附加参数
                smartDisplay: false, // 智能显示 pagination 和 cardview 等
                toolbar: ".toolBar", //顶部工具菜单
                toolbarAlign: "right", //顶部工具位置
                mobileResponsive: "true", //手机模式自适应宽度（自动变成卡片模式）
                columns: [
                    {
                    	  field: 'rowno',
                          title: '序号',
                          formatter: function (value, row, index) {  
                              return index+1;  
                          },  
                          align:'center'
                    }, {
                        field: 'name',
                        title: '姓名',
                        align: 'center'
                    }, {
                        field: 'sex',
                        title: '性别',
                        formatter: function (value) {
                        	  var result = null;
                              switch (value) {
                                  case 1:
                                      result = "男";
                                      break;
                                  case 2:
                                      result = "女";
                                      break;
                                  default:
                                      result = "未知";
                                      break;
                              }
                              return result;
                        }
                    }, {
                        field: 'nation',
                        title: '民族',
                        formatter: function (value) {
                        	var result = null;
                        	switch(value)
                        	{
                        	case  1:result="汉族";  break;
                        	case  2:result="阿昌族";  break;
                        	case  3:result="白族";  break;
                        	case  4:result="保安族";  break;
                        	case  5:result="布朗族";  break;
                        	case  6:result="布依族";  break;
                        	case  7:result="朝鲜族";  break;
                        	case  8:result="达斡尔族";  break;
                        	case  9:result="傣族";  break;
                        	case  10:result="德昂族";  break;
                        	case  11:result="侗族";  break;
                        	case  12:result="东乡族";  break;
                        	case  13:result="独龙族";  break;
                        	case  14:result="鄂伦春族";  break;
                        	case  15:result="俄罗斯族";  break;
                        	case  16:result="鄂温克族";  break;
                        	case  17:result="高山族";  break;
                        	case  18:result="仡佬族";  break;
                        	case  19:result="哈尼族";  break;
                        	case  20:result="哈萨克族";  break;
                        	case  21:result="赫哲族";  break;
                        	case  22:result="回族";  break;
                        	case  23:result="基诺族";  break;
                        	case  24:result="京族";  break;
                        	case  25:result="景颇族";  break;
                        	case  26:result="柯尔克孜族";  break;
                        	case  27:result="拉祜族";  break;
                        	case  28:result="黎族";  break;
                        	case  29:result="傈僳族";  break;
                        	case  30:result="珞巴族";  break;
                        	case  31:result="满族";  break;
                        	case  32:result="毛南族";  break;
                        	case  33:result="门巴族";  break;
                        	case  34:result="蒙古族";  break;
                        	case  35:result="苗族";  break;
                        	case  36:result="仫佬族";  break;
                        	case  37:result="纳西族";  break;
                        	case  38:result="怒族";  break;
                        	case  39:result="普米族";  break;
                        	case  40:result="羌族";  break;
                        	case  41:result="撒拉族";  break;
                        	case  42:result="畲族";  break;
                        	case  43:result="水族";  break;
                        	case  44:result="塔吉克族";  break;
                        	case  45:result="塔塔尔族";  break;
                        	case  46:result="土族";  break;
                        	case  47:result="土家族";  break;
                        	case  48:result="佤族";  break;
                        	case  49:result="维吾尔族";  break;
                        	case  50:result="乌兹别克族";  break;
                        	case  51:result="锡伯族";  break;
                        	case  52:result="瑶族";  break;
                        	case  53:result="彝族";  break;
                        	case  54:result="裕固族";  break;
                        	case  55:result="藏族";  break;
                        	case  56:result="壮族";  break;
                        	default:
                        	  result=="未知";  break;
                        	}
                        	 return result;
                        }
                    },
                    {
                        field: 'job',
                        title: '职务',
                        formatter: function (value) {
                            var result = null;
                            switch (value) {
                                case 1:
                                    result = "食品安全技术人员";
                                    break;
                                case 2:
                                    result = "食品安全管理人员";
                                    break;
                                case 3:
                                    result = "其他人员";
                                    break;
                                default:
                                    result = "未知";
                                    break;
                            }
                            return result;
                        }
                    }, {
                        field: 'cardNumber',
                        title: '身份证号码',
                        align: 'center'
                    }, {
                        field: 'phone',
                        title: '手机号码',
                        align: 'center'
                    }, {
                        field: 'action',
                        title: '操作',
                        align: 'center',
                        formatter: operateFormatter,
                        events: operateEvents
                    }
                ]
            });
            //查询条件  
            function queryParams(params) {  
            	var applyId=$("#applyId").val();
            	var changeId=$("#changeId").val();
            	if(changeId==undefined){
            		return {  
            			job:"1",
            			applyId:applyId
            		};  
            	}
            	if(applyId==undefined){
            		return {  
            			job:"1",
            			changeId:changeId
            		};  
            	}
            }  

        },

        /**
         * 查看
         */
        view: function () {

        },

        /**
         *编辑保存
         */
        save: function () {
        }
     }
});


